package com.sk.bilibili.model.fragment.search;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.bean.VideoSet;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.dto.Page;
import com.sk.bilibili.mapper.SearchMapper;
import com.sk.bilibili.other.JsonMap;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.search.VideoSetFragment;

public class VideoSetModel extends BaseSearchModel<VideoSetFragment>{

    @Autowired
    SearchMapper searchMapper;

    @Override
    public void loadData() {
        JsonMap map = getJsonMap();
        RequestUtils.process(searchMapper.searchVideo(map), videoSetPage -> {
            view.addData(videoSetPage.getRecords());
            page++;
        });
    }

    @Override
    public void refreshData() {
        page=1;
        JsonMap map = getJsonMap();
        RequestUtils.process(searchMapper.searchVideo(map), videoSetPage -> {
            view.setData(videoSetPage.getRecords());
            view.setNum(videoSetPage.getTotal());
            page++;
        });
    }

}